package com.huang.service;

import com.huang.mapper.AttractionsMapper;
import com.huang.mapper.OrderMapper;
import com.huang.pojo.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class OrderServiceImpl implements OrderService{

    @Autowired
    private OrderMapper orderMapper;
    @Autowired
    private AttractionsMapper attractionsMapper;


    @Override
    public List<Order> getOrderList() {
        return orderMapper.getOrderlist();
    }

    //用户购票的
    @Transactional
    @Override
    public int addOrder(String username, String atrname, String ticketle, Integer num,double price) {



        attractionsMapper.updateticketnum(num,atrname);
        return orderMapper.addOrder(username,atrname,ticketle,num,price);

    }

    @Override
    public List<Order> getUserOrder(String username) {
       return orderMapper.getUserOrder(username);
    }


}
